package org.jeecg.modules.demo.zjzx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.zjzx.entity.ZwglWt;
import org.jeecg.modules.demo.zjzx.mapper.ZwglZjhdMapper;
import org.jeecg.modules.demo.zjzx.mapper.ZwglWtMapper;
import org.jeecg.modules.demo.zjzx.service.IZwglWtService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 专家诊断
 * @Author: jeecg-boot
 * @Date:   2023-04-20
 * @Version: V1.0
 */
@Service
public class ZwglWtServiceImpl extends ServiceImpl<ZwglWtMapper, ZwglWt> implements IZwglWtService {

	@Autowired
	private ZwglWtMapper zwglWtMapper;
	@Autowired
	private ZwglZjhdMapper zwglZjhdMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		zwglZjhdMapper.deleteByMainId(id);
		zwglWtMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			zwglZjhdMapper.deleteByMainId(id.toString());
			zwglWtMapper.deleteById(id);
		}
	}
	@Override
	public Result listByUser(String twrxm) {
		QueryWrapper<ZwglWt> wrapper=new QueryWrapper<ZwglWt>();
		wrapper.eq("twrxm", twrxm);
		List<ZwglWt> problems = zwglWtMapper.selectList(wrapper);
		return Result.OK(problems);
	}
	
}
